new Vue({
	el: '#active',
	data: {
		currentLon: "",
		currentLat: "",
		list:[],
		chooseId:""
	},
	filters:{
		joinTypeFilter:filter.joinTypeFilter
	},
	methods: {
		plusReady: function() {
			this.getMeeting();
			plus.geolocation.getCurrentPosition(translatePoint, function(e) {});

			function translatePoint(position) {
				this.currentLon = position.coords.longitude;
				this.currentLat = position.coords.latitude;
			}
		},
		goMap: function(item, index) {
			if('Android' === plus.os.name && navigator.userAgent.indexOf('StreamApp') > 0) {
				plus.nativeUI.toast('当前环境暂不支持地图插件');
				return;
			}
			// 设置目标位置坐标点和其实位置坐标点
			var dst = new plus.maps.Point(116.39131928, 39.90793074);
			var src = new plus.maps.Point(this.currentLon, this.currentLat);
			// 调用系统地图显示 
			plus.maps.openSysMap(dst, "", src);

		},
		getMeeting: function() {
			var context = this;
			var  lan="ZH";
			if(localStorage.getItem("localLang")==0){
				lan="ZH";
			}else{
				lan="EN";
			}
			var ajax = {
				"language": lan
			}
			ajAjax("app/meeting/getMeeting.do", ajax, function(data) {
				context.list=data.Rows;
				var date = new Date().getTime();
				context.list.forEach(function(item){
					var endTime = new Date(item.endTime).getTime();
					if(endTime>date){
						item.ifEnd = '已报名'
					}else{
						item.ifEnd = '报名已截止'
					}
				});
			}, function(err) {
				mui.toast('获取活动列表失败')
			});
		},
		removeList: function(data) {
			data.forEach(function(e) {
				e.meetingFileList.forEach(function(e) {
					e.path=domain+e.path;
				});
			});
			this.list=data;
		},

		myActive: function() {
			commonOpenWindow("../pages/active/my-active.html", "../pages/active/my-active.html", null, "0")
		},
		gotoDatail:function(item,index){
			commonOpenWindow("active-detail.html", "active-detail.html", item, "0")
		},
		goSignUp: function(item) {
			if(item.joinType=="0"){
				this.chooseId = item.id;
				mui("#popover").popover('toggle', document.getElementById("div"));
			}
		},
		person: function() {
			var context = this;
			commonOpenWindow("../mine/sign-up-organize.html", "sign-up-organize.html",  context.chooseId, "0")
		},
		jg: function() {
			var context = this;
			commonOpenWindow("../mine/sign-up-personal.html", "sign-up-personal.html", context.chooseId, "0")
		},
		
	},
	mounted: function() {
		this.getMeeting()
		if(window.plus) {
			this.plusReady();
		} else {
			document.addEventListener("plusready", this.plusReady, false);
		}
	}
});